//-----------------------------------------------------------------------
// <copyright file="PendingContact.cs" company="Microsoft">
//     Copyright (c) Microsoft Corporation.  All rights reserved.
// </copyright>
//-----------------------------------------------------------------------

namespace Microsoft.Live.Messenger
{
    using System;

    /// <summary>
    /// Specifies a pending contact.
    /// </summary>
    public sealed class PendingContact
    {
        private readonly MessengerEntity entity;
        private readonly User user;

        internal PendingContact(MessengerEntity entity, User user)
        {
            this.entity = entity;
            this.user = user;
        }

        internal MessengerEntity Entity
        {
            get { return this.entity; }
        }

        /// <summary>
        ///     Gets the instant messaging address.
        /// </summary>
        public IMAddress IMAddress
        {
            get { return this.user.IMAddressFactory.FindOrCreate(this.entity.GetProperty("IMAddress")); }
        }

        /// <summary>
        ///     Gets the invite message that the address provided.
        /// </summary>
        public string InviteMessage
        {
            get { return this.entity.GetProperty<string>("InviteMessage"); }
        }

        /// <summary>
        ///     Accepts the pending contact.
        /// </summary>
        public void Accept()
        {
            this.entity.Invoke("Accept");
        }

        /// <summary>
        ///     Declines the pending contact.
        /// </summary>
        public void Decline()
        {
            this.entity.Invoke("Decline");
        }
    }
}